<template>
  <div>
    <BasicTable @register="registerTable">
      <template #toolbar>
        <a-button type="primary" @click="handleCreate"> 新增富友支付参数 </a-button>
      </template>
      <template #action="{ record }">
        <TableAction
          :actions="[
            {
              icon: 'clarity:note-edit-line',
              onClick: handleEdit.bind(null, record),
            },
          ]"
        />
      </template>
    </BasicTable>
    <Drawer @register="registerDrawer" @success="handleSuccess" />
  </div>
</template>
<script lang="ts" setup name="fuIouPayparam">
import { BasicTable, TableAction } from '@apps/antd-admin/src/components/Table';
import { useDrawer } from '@apps/antd-admin/src/components/drawer';
import Drawer from './drawer.vue';
import { columns, searchFormSchema } from './data';
import { useMessage } from '@apps/antd-admin/src/hooks/web/useMessage';
import { useBaseTable } from '@apps/antd-admin/src/hooks';
import { Api } from './api';
const { createMessage } = useMessage();
const [registerDrawer, { openDrawer }] = useDrawer();
const { prefixCls, tableContext, handleDelete, handlePost, handleBatchDelete } = useBaseTable({
  designScope: 'fuIouPayparam-template',
  tableProps: {
    //表格标题
    title: '富友支付参数列表',
    //主键字段
    rowKey: 'fuIouPayParamId',
    //列表接口
    listUrl: Api.page,
    //列定义
    columns: columns,
    //查询表单配置
    formConfig: {
      labelWidth: 120,
      schemas: searchFormSchema,
    },
    //操作列配置
    actionColumn: {
      width: 240,
      title: '操作',
      dataIndex: 'action',
      slots: { customRender: 'action' },
      fixed: 'right',
    },
    clickToRowSelect: true,
    rowSelection: {
      type: 'radio',
    },
  },
});

const [registerTable, { getForm, setProps, reload }, { rowSelection, hasSelectedRows, selectedRow }] = tableContext;

function handleCreate() {
  openDrawer(true, {
    isUpdate: false,
  });
}

function handleEdit(record: Recordable) {
  openDrawer(true, {
    record,
    isUpdate: true,
  });
}

function handleSuccess() {
  reload();
}
</script>
